package com.example.kekewaimaibao.core.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

import java.util.ArrayList;

/**
 * @author: xuxiang
 * @date: 2022/3/8 23:33 星期二
 * @description:
 * @version: 1.0
 */
@Configuration
@EnableSwagger2
public class SwaggerConfig {
    // 配置了Swagger的Docket的bean实例
    @Bean
    public Docket docket() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.example.kekewaimaibao"))
                .paths(PathSelectors.any())
                .build();
    }

    // 配置Swagger信息
    private ApiInfo apiInfo() {

        // 作者信息
        Contact contact = new Contact("name","url","email");

        return new ApiInfo(
                "徐翔的SwaggerAPI文档",
                "刻刻外卖宝",
                "v1.0",
                "https://blog.csdn.net/weixin_44023498",
                contact,
                "Apache 2.0",
                "http://www.apache.org/licenses/LICENSE-2.0",
                new ArrayList()
        );
    }
}
